

jQuery(document).ready(function(){
	setClick();

});

function setClick(){
	
	jQuery('#weather_update').click(function() { //start function when any update link is clicked
		getWeather(jQuery('#coolDiary_city').attr("value"));
	});
	
	jQuery('#coolDiary_city').blur(function() { //start function when any update link is clicked
		
		getWeather(jQuery('#coolDiary_city').attr("value"));
	});
	
	
}


function getWeather(city) {

	jQuery.ajax({
		type: "post",url: "admin-ajax.php",data: { action: 'getWeather','city':city},
		beforeSend: function() {				
			//jQuery("#coolDiary_weather").fadeOut('fast');
			jQuery("#coolDiary_weather").attr("value",'Loading...');}, //fadeIn loading just when link is clicked
		success: function(html){ //so, if data is retrieved, store it in html
			
			jQuery("#coolDiary_weather").attr("value",html); //fadeIn the html inside helloworld div
			//jQuery("#coolDiary_weather").fadeIn("fast"); //animation
			
		}
	}); //close jQuery.ajax(
}
